package com.aaa.methodreference.demo05;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.print.Doc;
import java.util.function.Function;
import java.util.function.Supplier;

/**
 * @author C-Q
 * @version 1.1.0
 * @Description: 构造方法的引用
 * @date 2022/11/4
 */
public class Test01 {
    public static void main(String[] args) {
        //Function<String,Doctor> function=(t)->new Doctor(t);
        /*构建方法的引用  类名::new    (args)->new 类名(args)*/
        Function<String,Doctor> function=Doctor::new;

        //Supplier<Doctor> supplier=()->new Doctor();
        //Supplier<Doctor> supplier=Doctor::new;
        //System.out.println(supplier);

        Doctor doctor=function.apply("张惠妹");
        System.out.println("doctor = " + doctor);
    }
}
@Data
@NoArgsConstructor
@AllArgsConstructor
class Doctor{
    private String name;
}